<script src="/i/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/i/codemirror/lib/codemirror.css">
<script src="/i/codemirror/addon/edit/closetag.js"></script>
<script src="/i/codemirror/addon/fold/xml-fold.js"></script>
<script src="/i/codemirror/mode/xml/xml.js"></script>
<script src="/i/codemirror/mode/javascript/javascript.js"></script>
<script src="/i/codemirror/mode/css/css.js"></script>
<script src="/i/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<style type="text/css" id=style>
	.CodeMirror {border: 1px solid #E5E1DB; height: 450px;}
</style>
<div class="row">
	<ol class="breadcrumb">
		<li><a href="<{url c='admin/article' a='index'}>">文章管理</a></li>
		<li><a href="<{url c='admin/template' a='index'}>">模板</a></li>
		<{if !empty($info)}>
		<li class="active">编辑模板：<{$info.template_name}></li>
		<{else}>
		<li class="active">增加新模板</li>
		<{/if}>
	</ol>
</div>
<div class="row">
	<{if !empty($info)}>
	<form class="form-horizontal" method="POST" action="<{url c='admin/template' a='edit'}>">
		<input type="hidden" name="template_id" value="<{$info.template_id}>">
	<{else}>
	<form class="form-horizontal" method="POST" action="<{url c='admin/template' a='add'}>">
	<{/if}>
		<div class="form-group">
			<label for="inputType" class="col-sm-2 control-label">模板类型</label>
			<div class="col-sm-6">
				<select class="form-control" id="inputType" name="template_type" <{if !empty($info)}>disabled="disabled" readonly<{/if}>>
					<{foreach $template_type as $typekey => $typename}>
					<option value="<{$typekey}>"<{if !empty($info) && $typekey==$info.template_type}> selected<{/if}>><{$typename}></option>
					<{/foreach}>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label for="inputName" class="col-sm-2 control-label">模板名称</label>
			<div class="col-sm-6">
				<input type="text" name="template_name" value="<{if !empty($info)}><{$info.template_name}><{/if}>" class="form-control" id="inputName" placeholder="模板名称">
			</div>
		</div>
		<div class="form-group">
			<label for="inputPath" class="col-sm-2 control-label">文件名</label>
			<div class="col-sm-6">
				<input type="text" name="filename" class="form-control" id="inputPath" placeholder="文件名" <{if !empty($info)}> disabled="disabled" readonly value="<{$info.filename}>" <{/if}>>
			</div>
		</div>
		<div class="form-group">
			<label for="code" class="col-sm-2 control-label">模板内容</label>
			<div class="col-sm-8">
				<textarea id="code" name="code"><{if !empty($info)}><{$code}><{/if}></textarea>
			</div>
		</div>
		<div class="form-group">
			<div class="col-sm-offset-2 col-sm-8">
				<button type="submit" class="btn btn-default">提交</button>
			</div>
		</div>
	</form>
</div>
<script type="text/javascript">
    var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
        mode: 'text/html',
        autoCloseTags: true,
        lineNumbers: true,
        lineWrapping: true
    });
</script>
